package com.cgwx.commonutils.math.function;

/**
 * @author GaoWei
 * @Date 2021/8/6 - 9:40
 */
public class FactFunction implements Function
{
    @Override
    public double of(double[] d, int numParam)
    {
        int n = (int)d[0];

        double result = 1.0D;
        for (int i = n; i > 1; i--) {
            result *= i;
        }
        return result;
    }

    @Override
    public boolean acceptNumParam(int numParam)
    {
        return numParam == 1;
    }

    public String toString()
    {
        return "fact(n)";
    }
}
